<template>
  <div class="categary">
    <ul>
      <li v-for="(item, index) in PROJECTDATA" :key="index" :class="
        `square-container swiper-slide animate__animated animate__fadeInUp animate__delay-0${index}s`
      ">
        <div class="box">
          <div class="mask1" @click="newWorkspace(item)">
            <svg class="icon svg-icon" aria-hidden="true">
              <use :xlink:href="'#'+item.icon1"></use>
            </svg>
            <dd>
              <i class="appIcon-iconfont appIcon-chuangjian"></i>
            </dd>
          </div>
          <div class="folder-color">
            <i :class="[
                'appIcon-iconfont',
                item.icon,
            ]"></i>
          </div>
        </div>
        <p>{{item.name}}</p>
      </li>
    </ul>
  </div>
</template>
<script lang="ts">
import { defineComponent, reactive } from 'vue'
import { useRouter } from 'vue-router'
import OfficeGlobal from '@/utils/officeglobal'
// import request from '@/utils/request'
import { PROJECTDATA } from '@/configs/projectdata'
import { addCcontent } from "@/api/content"
export default defineComponent({
  name: 'categary',
  props: {
    folderId: {
      type: String || Number,
      required: true,
    },
    officeFileType: {
      type: String || Number,
      required: true,
    },
  },
  setup(props) {
    const router = useRouter()
    const newWorkspace = (item:any) => {
      // const params = {
      //   width: item.width,
      //   height: item.height,
      //   bgColor: "#fff",
      //   bgImage: "",
      //   content: "",
      //   percent: item.percent,
      // }
      // request.post(`/hhxs-ssc/sc/chart/saveOrUpdate`,params).then(res => {
      //   router.push({
      //     path: '/freeeditor',
      //     query: {
      //       wid: res.data.data,
      //       name: item.name
      //     }
      //   })
      // })
      // console.log('props.folderId',props.folderId);
      const params = {
        "officeFileType": 2,
        "officeOwnership": 1,
        // "officeParentId": props.folderId == '-1' ? 0 : props.folderId,//创建内容的父级id 
        "officeLabelId": props.folderId == '-1' ? 0 : props.folderId,//创建内容的父级id 
        "officeHeight": item.height,
        "officeWidth": item.width,
        "officePercent": item.percent,
        "officeTitle": "未命名",
        "officeType": OfficeGlobal.officeType
      }
      addCcontent(params).then((res:any) => {
        // console.log("新建成功：", res.data.data)
        const pId = res.data.data
        if (pId) {
          let pptName = ''
          // toEdietPage(pptName.value,pId)
          router.push({
            path: '/freeeditor',
            query: {
              wid: res.data.data,
              name: item.name
            }
          })
        }
      })
    }
    return {
      props,
      newWorkspace,
      PROJECTDATA
    }
  }
})
</script>

<style lang="scss" scoped>
.categary {
  overflow: hidden;
  height: 243px;
  margin-bottom: 30px;

  ul {
    display: flex;
    margin-top: 30px;
    overflow: hidden;
    overflow-x: scroll;
    padding-bottom: 30px;
    padding-right: 20px;

    li {
      height: 100%;
      margin: 0 20px;
      flex: 1;
      text-align: center;
      cursor: pointer;

      p {
        padding-top: 20px;
        color: $textColor;
        font-size: 18px;
      }

      .box {
        position: relative;
        height: 170px;
        box-shadow: 0 20px 40px 0 rgba(53, 104, 212, 0.1);
        border-radius: 16px;
        background: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 10px;

        .svg-icon {
          width: 54px;
          height: 54px;
          position: absolute;
          top: 50%;
          left: 50%;
          margin-left: -27px;
          margin-top: -27px;
        }

        .folder-color {
          padding: 10px;

          i {
            font-size: 80px;
            color: #edeff9;
          }
        }
      }

      .mask1 {
        position: absolute;
        width: 100%;
        height: 100%;
        left: 0;
        top: 0;
        text-align: center;
        border-radius: 16px;
        transition: 0.5s all ease;

        dd {
          display: none;
          width: 54px;
          height: 54px;
          border-radius: 50%;
          position: absolute;
          top: 50%;
          left: 50%;
          margin-left: -27px;
          margin-top: -27px;
          background: $textH2Color;
          line-height: 54px;
          text-align: center;

          .appIcon-iconfont {
            font-size: 24px;
            color: #fff;
          }
        }
      }

      &:nth-child(2) {
        .box {
          dd {
            background: #ffc107;
          }

          &:hover .mask1 {
            border-color: #ffc107;
          }
        }
      }

      &:nth-child(3) {
        .box {
          dd {
            background: #4ac367;
          }

          &:hover .mask1 {
            border-color: #4ac367;
          }
        }
      }

      &:nth-child(4) {
        .box {
          dd {
            background: #8d6e63;
          }

          &:hover .mask1 {
            border-color: #8d6e63;
          }
        }
      }

      &:nth-child(5) {
        .box {
          dd {
            background: #00bcd4;
          }

          &:hover .mask1 {
            border-color: #00bcd4;
          }
        }
      }

      &:nth-child(6) {
        .box {
          dd {
            background: #da5df5;
          }

          &:hover .mask1 {
            border-color: #da5df5;
          }
        }
      }

      &:nth-child(7) {
        .box {
          dd {
            background: #ff7826;
          }

          &:hover .mask1 {
            border-color: #ff7826;
          }
        }
      }
    }
  }
}

.box {
  &:hover {
    .mask1 {
      border: 2px solid $textH2Color;
      background: rgba(0, 0, 0, 0.1);

      .svg-icon {
        display: none;
      }

      dd {
        display: block;
      }
    }
  }
}
</style>